package com.example.secondhand.common.enums;
public enum StatusEnum {
    ENABL((byte) 1, "启用"),
    DISABLE((byte) 0, "禁用"),
    DELETE((byte) -1, "删除");

    private final byte code;
    private final String description;

    StatusEnum(byte code, String description) {
        this.code = code;
        this.description = description;
    }

    public byte getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static StatusEnum fromCode(byte code) {
        for (StatusEnum status : StatusEnum.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    @Override
    public String toString() {
        return this.name() + "(" + this.code + ": " + this.description + ")";
    }

}
